class Solution {
public:
    vector<string> uncommonFromSentences(string s1, string s2) {
        unordered_set<string> ret;
        unordered_set<string> hash;
        string s = s1 + " " + s2;
        int i = 0;
        int j = 0;
        for(;j <= s.size();j++){
            if(j == s.size() || s[j] == ' '){
                string ans = s.substr(i,j-i);
                if(hash.count(ans) && ret.count(ans)){
                    ret.erase(ans);
                }
                if(!hash.count(ans)){
                    hash.insert(ans);
                    ret.insert(ans);
                }
                i = j+1;
            }
        }
        return vector<string>(ret.begin(),ret.end());
    }
};
